import axios from "axios"
import shoesUrls from "../../urls/product/shoes"

export default {
  // 分页获取所有鞋子
  fetchGetShoesByPage (params) {
    return axios.post(shoesUrls.getShoesByPage, {"pageNum": params.get("pageNum"), "pageSize": params.get("pageSize")}, { headers: { "Content-Type": "application/json" } })
  },
  // 分页获取鞋子对应的类型
  fetchGetShoesTypesByPage (params) {
    return axios.post(shoesUrls.getShoesTypesByPage, params)
  },
  // 分页获取所有鞋子对应品牌
  fetchGetShoesBrandsByPage (params) {
    return axios.post(shoesUrls.getShoesBrandsByPage, params)
  },
  // 分页获取所有鞋子对应颜色
  fetchGetShoesColorsByPage (params) {
    return axios.post(shoesUrls.getShoesColorsByPage, params)
  },
  // 分页获取所有鞋子产地
  fetchGetShoesProducerByPage (params) {
    return axios.post(shoesUrls.getShoesProducerByPage, params)
  },
  // 添加鞋子
  fetchAddShoes (data) {
    return axios.post(shoesUrls.addShoes, data)
  },
  // 修改鞋子
  fetchEditShoes (data) {
    return axios.post(shoesUrls.editShoes, data)
  },
  // 批量禁用/解禁
  fetchBatchChangeState (data) {
    return axios.post(shoesUrls.batchChangeState, data)
  },
  // 校验鞋子名称是否唯一
  fetchCheckShoes (sname) {
    return axios.post(shoesUrls.checkShoes + "?sname=" + sname)
  },
  fetchCheckSnum (snum) {
    return axios.post(shoesUrls.checkSnum + "?snum=" + snum)
  },
  // 上传图片
  fetchUploadPhoto (spurlData) {
    return axios.post(shoesUrls.uploadPhoto, spurlData, { headers: { "Content-Type": "multipart/form-data" } })
  },
  // 删除图片
  fetchDeletePhoto (sid, fileName) {
    return axios.post(shoesUrls.deletePhoto + "?sid=" + sid + "&fileName=" + fileName)
  },
  // 根据鞋子id获取鞋子对象(包括照片和尺码库存)
  fetchGetShoesById (sid) {
    return axios.post(shoesUrls.getShoesById + "?sid=" + sid)
  }
}
